package cc.io24.knewcafe.blog.domain;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

@Entity
@EntityListeners(AuditingEntityListener.class)
@SQLDelete(sql = "update post set is_deleted = 1 where id = ?")
@Where(clause = "is_deleted = 0")
@org.hibernate.annotations.Table(appliesTo = "post", comment = "文章表")
public class Post implements Serializable {

    @Id
    @GeneratedValue(generator = "uuid4i")
    @GenericGenerator(name = "uuid4i", strategy = "uuid2")
    @Column(name = "id", columnDefinition = "varchar(64) not null comment 'id'")
    private String id;

    @Column(name = "title", columnDefinition = "varchar(256) not null comment '标题'")
    private String title;

    @Column(name = "content", columnDefinition = "text comment '内容'")
    private String content;

    private String server;

    @Column(name = "is_deleted")
    private Integer isDeleted = 0;

    @CreatedDate
    @Column(name = "create_date", updatable = false)
    private Date createDate;

    @LastModifiedDate
    @Column(name = "lastModified_date")
    private Date lastModifiedDate;


    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Integer getIsDeleted() {
        return isDeleted;
    }

    public void setIsDeleted(Integer isDeleted) {
        this.isDeleted = isDeleted;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public Date getLastModifiedDate() {
        return lastModifiedDate;
    }

    public void setLastModifiedDate(Date lastModifiedDate) {
        this.lastModifiedDate = lastModifiedDate;
    }

    public String getServer() {
        return "sever1";
    }

    public void setServer(String server) {
        this.server = server;
    }
}
